﻿#light

module PubSim.CappuccinoMix

open System
open Microsoft.FSharp.Control

/// Cappuccino mix type definition ... used to set status of whether the cappuccino mix is
/// on the shelf or not.
type CappuccinoMix(initValue) =
    let mutable cappuccinoMix = initValue
    let lockObj = new Object()

    member c.AddCappuccinoMixToCupboard() =
        cappuccinoMix <- true
        ignore()
    member c.FetchCappuccinoMixFromCupboard() =
        lock lockObj (fun() ->
            if cappuccinoMix = true then
                cappuccinoMix <- false
                true
            else
                false
        )
    member c.IsCappuccinoMixInCupboard() =
        cappuccinoMix
